fix: stop queued jobs from failing in-progress babysit runs - #167
Merged
jeremymcs merged 2 commits intoAug 18, 2026
Merged
Conversation
jeremymcs
force-pushed
the
codex/fix-spurious-interrupted-run-failure
branch
from
August 18, 2026 08:29
7716ac2 to
6f71213
Compare
Owner
|
Rebased onto This branch carried four commits that One real conflict needed resolving: Verified locally: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The PRs page showed a spurious failed run:
Failed / run.failed / codex / Interrupted run missing replay context, even though the underlying run was still actively working.Root cause
A
babysit_prbackground job can fire while a run for the same PR is already live in the process (the watcher re-queues follow-up work every sweep, e.g. while mergeable state is unstable).runQueuedBabysitPRthen treated the active run as an "interrupted run" and — because its replay context (prompt/resolvedAgent/initialHeadSha) had not been persisted yet (in the merge-conflict path the prompt is never persisted at all) — marked itfailedwith "Interrupted run missing replay context". The follow-upbabysitPRcall was then skipped by the in-progress guard, leaving a bogusFailedentry visible in the UI until the live run's next record update overwrote it (minutes later during a long agent run).Fix
runQueuedBabysitPRnow first checks whether this process already has an active in-memory run for the PR (isRunAlreadyInProgress) and returns early if so, mirroring the existing guard inbabysitPR. Recovery after a real server restart is unaffected: on restart the in-memory map is empty, so stale "running" runs are still recovered or re-run as before.The in-progress guard was extracted into a shared private helper used by both
babysitPRandrunQueuedBabysitPRso the skip log stays identical.Tests
runQueuedBabysitPR does not mark a live in-progress run failed when a queued job fires before replay context is persisted(fails without the fix: the run is marked failed with the "Interrupted run missing replay context" error).node --import tsx --test server/babysitter.test.ts(111 tests pass),npm run checkpasses.